<!--
	作者：956911785@qq.com
	时间：2019年5月18日11:34:11
	描述：社团活动辅导班-添加
-->

<template>
	<Modal :title="title" v-model="modal0" width="800px">
		<Form ref="params" :model="params" :rules="ruleValidate" :label-width="100" label-position="left">
			<div style="width:100%;height:320px; overflow-y: hidden;">
		      	<div style="width:100%;height: 60px;line-height: 60px;float:left;">
		        	<div style="width: 80%;text-align: left;float: left;" align="left">
				        <FormItem  label="学校所在地区">
				        	<label style="float:left;" >播州区</label>
				        	<Select v-model="params.zhen" style="width:50%;float:left;padding-left:2px;" clearable>
						        <Option v-for="item in areas" :value="item.TNID" :key="item.TNNAME">{{ item.TNNAME }}</Option>
						    </Select>
		        		</FormItem>
		        	</div>
		        
		        </div>

				<div style="width:100%;height: 60px;line-height: 60px;float:left;">
		        	<div style="width: 50%;text-align: left;float: left;" align="left">
				        <FormItem  prop="csname" label="学校名称">
				        	<Input v-model="params.csname" placeholder="请输入学校名称" clearable style="width: 70%"></Input>
		        		</FormItem>
		        	</div>
		        	<div style="width: 50%;text-align: left;float: left;" align="left">
				        <FormItem  prop="csnum" label="校区号">
				        	<Input v-model="params.csnum" placeholder="请输入校区号" clearable style="width: 70%"></Input>
		        		</FormItem>
		        	</div>
		       </div>
		        
		        <div style="width:100%;height: 60px;line-height: 60px;float:left;">
		        	<div style="width: 50%;text-align: left;float: left;" align="left">
				        <FormItem label="学校标识码">
				        	<Input v-model="params.csschid" placeholder="请输入学校标识码" clearable style="width: 70%"></Input>
		        		</FormItem>
		        	</div>	
		        	<div style="width: 50%;text-align: left;float: left;" align="left">
				        <FormItem label="学校别名">
				        	<Input v-model="params.csalias" placeholder="请输入学校别名" clearable style="width: 70%"></Input>
		        		</FormItem>
		        	</div>
		        </div>
		        
		        
		  	 	<div style="width:100%;height: 60px;line-height: 60px;float:left;">
		        	<div style="width: 50%;text-align: left;float: left;" align="left">
				        <FormItem  prop="cssite" label="学校地址">
				        	<Input v-model="params.cssite" placeholder="请输入学校地址" clearable style="width: 70%"></Input>
		        		</FormItem>
		        	</div>	
		        	<div style="width: 50%;text-align: left;float: left;" align="left">
				        <FormItem  prop="csphone" label="学校电话">
				        	<Input v-model="params.csphone" placeholder="请输入学校电话" clearable style="width: 70%"></Input>
		        		</FormItem>
		        	</div>
		        </div>
		     
		     	<div style="width:100%;height: 60px;line-height: 60px;float:left;">
		        	<div style="width: 50%;text-align: left;float: left;" align="left">
				        <FormItem  prop="csxz" label="校长姓名">
				        	<Input v-model="params.csxz" placeholder="请输入校长姓名" clearable style="width: 70%"></Input>
		        		</FormItem>
		        	</div>	
		        	<div style="width: 50%;text-align: left;float: left;" align="left">
				        <FormItem  prop="csxzphone" label="校长联系电话">
				        	<Input v-model="params.csxzphone" placeholder="请输入校长联系电话" clearable style="width: 70%"></Input>
		        		</FormItem>
		        	</div>
		        </div>
		        
		     
		   </div> 
	    </Form>
	   	<div slot="footer">
	    	<Button type="text"  @click="closeModal()">取消</Button>
	    	<Button type="primary" @click="addsave()" >确定</Button>
	    </div>
     </Modal>
</template>

<script>

	
	export default {
		name:"tconent",
		props: {
    		teas:{
    			type:Object,	
    			default: function() {
					return null
				}
    		},
    		title:{
    			type:String,	
    		},
    	},
		data() {
			//长度控制
			const lenPass = (rule, str, callback) => {
			  if(str.length>rule.length){
			  	 callback(new Error('字符串长度在1-'+rule.length+'之间！'));
			  }
			  return callback();
			};
			
			//正整数控制
			const zzsPass1 = (rule, value, callback) => {
			    let reg = /^\+?[1-9][0-9]*$/; 
				if(!reg.test(value)){
				    callback(new Error('请输入正整数！'));
				}else{
				  	return callback();
				}
			};
			//正数控制
			const zsPass = (rule, value, callback) => {
			    let reg = /^\+?[1-9]|[1-9][0-9]*$/; 
				if(!reg.test(value)){
				    callback(new Error('请输入正数！'));
				}else{
				  	return callback();
				}
			};
			return {
				ruleValidate: {
		            csname: [
		                {required: true, message: '请输入校区名称！', trigger: 'blur'},
		                {length:30,validator:lenPass,trigger:'blur'}
		            ],
					csnum: [
		                {required: true, message: '请输入校区号！', trigger: 'blur'},
		                {validator:zzsPass1,trigger:'blur'}
		            ],
					cssite: [
		                {required: true, message: '请输入学校地址！', trigger: 'blur'},
		                {length:100,validator:lenPass,trigger:'blur'}
		            ],
					csphone: [
		                {required: true, message: '请输入学校电话！', trigger: 'blur'},
		                {length:30,validator:lenPass,trigger:'blur'}
		            ],
		            csxz: [
		                {required: true, message: '请输入校长姓名！', trigger: 'blur'},
		                {length:30,validator:lenPass,trigger:'blur'}
		            ],
		            csxzphone: [
		                {required: true, message: '请输入校长联系电话！', trigger: 'blur'},
		                {length:30,validator:lenPass,trigger:'blur'}
		            ],
		      
		           
		        },   
                modal0:false,
                params:{
                	pcaid:'', 
					pcalv:'3',
					zhen:'',
					csid:'', 
					csname:'', 
					csnum:'',  
					csschid:'',  
					csalias:'',  
					cssite:'',  
					csphone:'',  
					csxz:'', 
					csxzphone:'', 
                },
			}
		},
		methods: {
			addsave:function(){
				this.$refs.params.validate((valid) => {
					if (valid){
						const params={...this.params};
						this.$emit("addsave",params);
                    }
               })
	        }, 
			
            closeModal(){
	      	    this.modal0 = false;
	      	    this.resetpar();
	        },
	        resetpar(){
	        	this.params={
	        		pcaid:'', 
					pcalv:'3',
					zhen:'',
					csid:'', 
					csname:'', 
					csnum:'',  
					csschid:'',  
					csalias:'',  
					cssite:'',  
					csphone:'',  
					csxz:'', 
					csxzphone:'', 
				};
	        },
	   
		},
		mounted() {
		
  			
		},
		watch:{
			modal0(news,olds){
				if(!news){
					 this.resetpar();
				}else{
					this.params={...this.teas};
				}
			}
		},
		computed: {
			areas: function() {
				return this.$store.state.app.areas;
			},
		}
		
	}
</script>

<style scoped="scoped">
	
</style>



